<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
 */

$app->get('/', function () use ($app) {
    return str_random(32);
});
//忘记密码
$app->post('user/resetPW', 'UserController@resetPW');
//im测试
$app->post('chat/imRegister', 'ChatController@imRegister');
$app->post('chat/imLogin', 'ChatController@imLogin');
$app->get('chat/oneChat', 'ChatController@oneChat');
$app->get('chat/userList', 'ChatController@userList');
$app->post('chat/broadcast', 'ChatController@broadcast');
$app->post('chat/notice', 'ChatController@notice');
$app->post('chat/sendBatchMsg', 'ChatController@sendBatchMsg');
$app->post('chat/sendMsg', 'ChatController@sendMsg');
$app->post('chat/customNotice', 'ChatController@customNotice');
//登录
$app->post('user/login', 'UserController@login');
//注册
$app->post('user/register', 'UserController@register');
//发送短信
$app->post('user/allSendMessage','UserController@allSendMessage');
//初始化
$app->post('user/initialize','UserController@initialize');
//初始化
$app->get('user/version/{id}','UserController@version');
//支付宝回调接口
$app->post('alipay/notify', 'App\PayController@notifyUrl');
$app->get('alipay/returnUrl', 'App\PayController@returnUrl');

 //自定义设置流程测试
$app->post('flow', 'App\FlowController@flow');
$app->post('process', 'App\FlowController@process');
$app->post('conclusion', 'App\FlowController@conclusion');
$app->post('reason', 'App\FlowController@reason');
$app->post('state', 'App\FlowController@state');

$app->post('flowGet', 'App\FlowController@get');
$app->put('flowUpdate/{id}/type/{type}', 'App\FlowController@update');

//验证验证码接口
$app->post('user/verifyMessage','UserController@verifyMessage');
//no auth web路由配置
$app->group(['prefix' => 'app/v1', 'namespace' => 'App'], function ($app) {
	//demo restful
    $app->get('item', 'ItemsController@all');
    $app->get('item/{id}', 'ItemsController@get');
    $app->post('item', 'ItemsController@add');
    $app->put('item/{id}', 'ItemsController@put');
    $app->delete('item/{id}', 'ItemsController@remove');
    
    $app->get('index', 'IndexController@all');
    //邮件发送
    $app->get('sendemail', 'VisitorhistoryController@sendemail');
    //邮件发送
    $app->get('sendSms', 'VisitorhistoryController@sendSms');
    //统计按钮点击模块次数
    $app->post('statistics/clickCount', 'StatisticsController@clickCount');
});

//auth web路由配置
$app->group(['prefix' => 'app/v1', 'namespace' => 'App', 'middleware' => 'authToken'], function ($app) {
    $app->get('userinfo', 'ItemController@userinfo');
    //公司logo，背景上传
    $app->post('company/upload', 'CompanyController@upload');
    //公司信息添加
    $app->post('company', 'CompanyController@add');
    //公司信息获取
    $app->get('company/{id}', 'CompanyController@get');
    //公司信息更新
    $app->put('company/{id}/step/{step}', 'CompanyController@update');
    //基本访客类型加载
    $app->get('setup/setTypeList/{id}', 'SetupController@setTypeList');
    //基本访客类型修改
//    $app->post('visitorSet/visitorTypeSet', 'visitorSetController@visitorTypeSet');
    //信息设置加载
    $app->get('setup/setInfoList/{id}', 'SetupController@setInfoList');
    $app->get('setup/setInfoIpad/{id}', 'SetupController@setInfoIpad');
    //信息设置修改
    $app->post('setup/setInfoSave', 'SetupController@setInfoSave');
    //便签信息设置
    $app->post('setup/setMome', 'SetupController@setMome');
    //旧密码修改密码
    $app->post('setup/changePW', 'SetupController@changePW');
//    //发送验证码
//    $app->get('setup/sendMessage/{id}', 'SetupController@sendMessage');
    //发送验证码
    $app->post('setup/sendMessage', 'SetupController@sendMessage');
    //进入设置时验证
    $app->post('setup/verifyPW', 'SetupController@verifyPW');
    //验证码验证
    $app->post('setup/verifyMessage', 'SetupController@verifyMessage');
    //便签信息加载
    $app->post('setup/momeInfo', 'SetupController@momeInfo');
    //总览
    $app->get('statistics/getOverView/{id}', 'StatisticsController@getOverView');
    //访问历史
    $app->post('statistics/getHistory', 'StatisticsController@getHistory');
    //周平均值
    $app->get('statistics/avgByWeek/{id}', 'StatisticsController@avgByWeek');
    //天平均值
    $app->get('statistics/avgByDay/{id}', 'StatisticsController@avgByDay');
    //拜访最多的人
    $app->get('statistics/whoMost/{id}', 'StatisticsController@whoMost');
    //访客邀请信息添加
    $app->post('visitorHistory', 'VisitorhistoryController@add');
    //访客邀请信息更新
    $app->post('visitorHistory/put/{id}', 'VisitorhistoryController@update');
    //访客/邀请单个详情
    $app->get('visitorHistory/{id}', 'VisitorhistoryController@get');
    //访客邀请信息所有获取
    $app->post('visitorHistory/all', 'VisitorhistoryController@all');
    //被搜索访问人列表
    $app->post('staffList', 'VisitorhistoryController@employeeInfoList');
    //今日访客数量
    $app->get('todayVisitors/{id}', 'VisitorhistoryController@todayVisitors');
    //最近一次被邀约或者以前来过
    $app->get('setDel', 'SetupController@setDel');
    //最近一次被邀约或者以前来过
    $app->post('lastRecord', 'VisitorhistoryController@lastRecord');
    //导出访客/邀请记录
    $app->post('excel/export','VisitorhistoryController@export');
    //导出访客/邀请记录
    $app->get('send/email','VisitorhistoryController@email');

    //组织结构
    $app->get('department', 'DepartmentController@all');
    $app->get('department/{id}/flag/{flag}', 'DepartmentController@get');
    $app->get('department/getStaff/{id}', 'DepartmentController@getStaff');
    $app->post('department', 'DepartmentController@add');
    $app->put('department/{id}', 'DepartmentController@put');
    $app->delete('department/{id}', 'DepartmentController@remove');

    //员工
    $app->post('staff', 'StaffController@add');
    $app->get('staff/{id}', 'StaffController@get');
    $app->put('staff/{id}', 'StaffController@put');
    $app->post('staff/remove', 'StaffController@remove');
    $app->post('staff/move', 'StaffController@moveStaff');
    $app->post('staff/import', 'StaffController@import');
    $app->post('staff/export', 'StaffController@export');

    //支付宝支付
    $app->post('pay', 'PayController@index');
    $app->post('gopay', 'PayController@gopay');

    //发票
    $app->post('invoice', 'InvoiceController@add');
    //消费记录
    $app->post('order/all', 'OrderController@all');
    $app->get('order/{id}', 'OrderController@get');
    $app->post('order/export', 'OrderController@export');

    //获取版本信息
    $app->get('version', 'VersionController@all');
});

//no auth ipad路由配置
$app->group(['prefix' => 'ipad/v1', 'namespace' => 'Ipad'], function ($app) {
    $app->get('index', 'IndexController@all');
});

//auth ipad路由配置
$app->group(['prefix' => 'ipad/v1', 'namespace' => 'Ipad', 'middleware' => 'authToken'], function ($app) {
    $app->get('home', 'HomeController@all');
    //用户关联设备
    $app->get('userDevice/{id}', 'UserdeviceController@get');
    $app->post('userDevice', 'UserdeviceController@add');
    $app->post('userDeviceUpdate', 'UserdeviceController@update');
});

